package cn.ubest.mvvmcore.widget;

import android.app.Dialog;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import org.jetbrains.annotations.Nullable;

import cn.ubest.mvvmcore.R;
import cn.ubest.mvvmcore.base.BaseDialogFragment;
import cn.ubest.mvvmcore.databinding.FragmentMyDialogLoadingBinding;
import cn.ubest.mvvmcore.utils.ResourcesUtils;


/**
 * Content: dialog 加载圈
 * Create by wk on 2019/7/22
 */
public class LoadingDialog extends BaseDialogFragment<FragmentMyDialogLoadingBinding> {

    public static LoadingDialog newInstance() {
        Bundle args = new Bundle();
        LoadingDialog fragment = new LoadingDialog();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void initDialog(Dialog dialog) {
        super.initDialog(dialog);
        prohibitCancel(dialog);
    }

    @Override
    public void initView(View view) {
        setWidth(getResources().getDimensionPixelSize(R.dimen.dp_80));
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
            setHeight(ResourcesUtils.getDimens(R.dimen.dp_120));
        } else {
            setHeight(ResourcesUtils.getDimens(R.dimen.dp_80));
        }
    }

    @Override
    protected void initWindow(Window window) {
        super.initWindow(window);
        WindowManager.LayoutParams windowParams = window.getAttributes();
        windowParams.dimAmount = 0.0f;

        window.setAttributes(windowParams);
    }


    @Override
    public int initLayout() {
        return R.layout.fragment_my_dialog_loading;
    }

    @Override
    public void initData(@Nullable Bundle arguments) {

    }

    @Override
    public void loadData() {

    }
}
